'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 生存
 * @author sundbcn@gmail.com (sun debing)
 */

var dataApi = require('../libs/dataApi');
var _ = require('lodash');
/**
 * 获取波数的配置
 * @param  {[type]} wave_num [description]
 * @return {[type]}          [description]
 */
exports.getWaveConf = function (wave_num) {
    var max_wave_num = dataApi.survive.length();
    if (wave_num > max_wave_num) {
        return dataApi.survive.findById(max_wave_num);
    }
    return dataApi.survive.findById(wave_num);
};

/**
 * 获取士兵的等级配置
 * @param  {[type]} soldier_type [description]
 * @return {[type]}              [description]
 */
exports.getSoldierListConf = function () {
    return dataApi.function_soldier_base.all();
};

/**
 * 获取奖励数据
 * @param  {[type]} wave_num [description]
 * @return {[type]}          [description]
 */
exports.getRewardListConf = function (job_type, wave_num) {
    var reward_list_all = dataApi.survive_reward.findById(wave_num);
    var reward_list = [];
    _.each(reward_list_all, function (survive_item) {
        if (survive_item.job_type === job_type) {
            reward_list.push(survive_item);
        }
    });
    return reward_list;
};
